﻿using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;
using System.Collections.Generic;
using OpenSda.Agilcont.Common.Business.Contracts;
using OpenSda.Agilcont.Common.Data.Entities;
using OpenSda.Agilcont.Common.Data.Contracts;
using OpenSda.Agilcont.Common.Business.Exceptions;
using System.Linq;

namespace OpenSda.Agilcont.Common.Business.SfContexts.NmTest
{
    [TestFixture]
    public class EmpresaBusinessTest : AbstractBaseDataTests
    {
        private IEmpresaBusiness target;
        public IEmpresaBusiness EmpresaBusiness { set { target = value; } }
        private IUserData userData;
        public IUserData UserData { set { userData = value; } }
        
        [Test]
        [ExpectedException(typeof(EmpresaCannotBeNullException))]
        public void SaveWhenEmpresaIsNullTest()
        {
            target.Save(null);
        }

        [Test]
        public void SaveTest()
        {
            Empresa empresa = this.Save();
            Assert.IsNotNull(empresa.Identity);
        }
        private Empresa Save()
        {
            //User u = userData.GetAll()[0];
            return target.Save(new Empresa()
            {
                Codigo = "187",
                RazonSocial="Gamarra latin",
                Ruc = "3234647484",
                Logo = "wertyuio"
                //UserManagementRef = u
                
            });
        }
        [Test]
        public void EmpresaGetByIdTests()
        {
            Empresa e = target.GetById("");
            Assert.IsNotNull(e);
        }

        private Empresa GetBayId()
        {
            return target.GetById(new object());

        }

        [Test]
        public void EmpresaGetLisByfiltertTests()
        {
            var e = target.GetListByFilter("");

            Assert.IsNotNull(e);
        }

        }


    }

